<?php
/**
 * SchoolRoom table data gateway
 *
 * @version $Id: SchoolRoom.php 73 2010-04-25 00:30:44Z yingkuang.chen@gmail.com $
 * @license New BSD License
 * @uses Zend_Db_Table_Abstract
 * @package school
 * @subpackage Model
 */
class School_Model_DbTable_SchoolRoom extends Zend_Db_Table_Abstract
{

	protected $_name = 'school_room';
	protected $_primary = 'sn';


	public function getParentCount()
	{

		$select = $this->getAdapter()->select()
		->from(array('t'=>'teacher_title'),
		array('t.division_sn','cc'=>'COUNT(*)'))
		->join(array('r'=>'school_room'),
		't.division_sn=r.sn',array())
		->group('t.division_sn');
		//echo $select;exit;
		$res = $this->getAdapter()->query($select)->fetchAll();
		$arr = array();
		foreach($res as $row) {
			$arr[$row['division_sn']] = $row['cc'];
		}
		return $arr;
	}


	public function  getKind() {
		$arr = array();
		$data = $this->fetchAll("enable='Y'");
		foreach ($data as $row) {
			$arr[$row->sn] = $row->name;
		}
		return $arr;
	}
}